<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use DB;
class EatEveryDay extends Model{

    protected $table = 'eat_every_day';
    public $timestamps = false;

    public function EatEveryDay($search = [], $page = 0, $length = 20){
        $sql = DB::table($this->table)->whereNull('deleted_at')->select();
        if(isset($search['search'])){
            $sql->where('name', $search['search']);
        }
        $list = $sql->skip(($page - 1)*$length)->take($length)
            ->orderBy('created_at', 'desc')
            ->get();
        return $list;
    }
    //修改
    public function saveEdit($data,$id){
        return \DB::table($this->table)->where('id',$id)->update($data);
    }
}
